package com.ruoyi.zhike.controller.account;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.zhike.db.domain.AccountMerchantInfo;
import com.ruoyi.zhike.account.service.IAccountMerchantInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.zhike.wrapper.AccountMerchantInfoWrapper;

/**
 * 商户账户信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/account/merAccountInfo")
public class AccountMerchantInfoController extends BaseController
{
    @Autowired
    private IAccountMerchantInfoService accountMerchantInfoService;

    /**
    *
    */
    @GetMapping("/extData")
    public AjaxResult extData() {
        JSONObject returnData = new JSONObject();

        return AjaxResult.success(returnData);
    }

    /**
     * 查询商户账户信息列表
     */
    @RequiresPermissions("account:merAccountInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(AccountMerchantInfo accountMerchantInfo)
    {
        startPage();
        List<Map<String, Object>> list = accountMerchantInfoService.selectAccountMerchantInfoListMap(accountMerchantInfo);
        list = new AccountMerchantInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出商户账户信息列表
     */
    @RequiresPermissions("account:merAccountInfo:export")
    @Log(title = "商户账户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountMerchantInfo accountMerchantInfo)
    {
        List<AccountMerchantInfo> list = accountMerchantInfoService.selectAccountMerchantInfoList(accountMerchantInfo);
        ExcelUtil<AccountMerchantInfo> util = new ExcelUtil<AccountMerchantInfo>(AccountMerchantInfo.class);
        util.exportExcel(response, list, "商户账户信息数据");
    }

    /**
     * 获取商户账户信息详细信息
     */
    @RequiresPermissions("account:merAccountInfo:query")
    @GetMapping(value = "/{accountId}")
    public AjaxResult getInfo(@PathVariable("accountId") Long accountId)
    {
        return success(accountMerchantInfoService.selectAccountMerchantInfoByAccountId(accountId));
    }

    /**
     * 新增商户账户信息
     */
    @RequiresPermissions("account:merAccountInfo:add")
    @Log(title = "商户账户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountMerchantInfo accountMerchantInfo)
    {
        return toAjax(accountMerchantInfoService.insertAccountMerchantInfo(accountMerchantInfo));
    }

    /**
     * 修改商户账户信息
     */
    @RequiresPermissions("account:merAccountInfo:edit")
    @Log(title = "商户账户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountMerchantInfo accountMerchantInfo)
    {
        return toAjax(accountMerchantInfoService.updateAccountMerchantInfo(accountMerchantInfo));
    }

    /**
     * 删除商户账户信息
     */
    @RequiresPermissions("account:merAccountInfo:remove")
    @Log(title = "商户账户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{accountIds}")
    public AjaxResult remove(@PathVariable Long[] accountIds)
    {
        return toAjax(accountMerchantInfoService.deleteAccountMerchantInfoByAccountIds(accountIds));
    }
}
